
path = require 'path'
fsp = require '../bin/libs/fs-promises'
fs = require 'fs'

a = "/Users/xurongzhi/test/rongzhi/a.text"
b = "/Users/xurongzhi/test/index.php"

zip = require '../bin/libs/zip'
Q = require 'q'
_ = require 'underscore'


_.each [1,2, 3], (each) ->
  console.log each
  return 1
  console.log 'ok'
# fsp.rename b, a
# .then () ->
#   console.log 2
# .catch (e) ->
#   console.log e


# fsp.writeFile a, 'ss'
# .then () ->
#   console.log 3
# .catch (e) ->
#   console.log e


# console.log path.join '/444///', '///////sss/'

# new Promise (resolve, reject) ->
#   console.log 2
#   # reject()
#   fsp.traverse_safe "/Users/xurongzhi/testw"
#   .then ->
#     resolve()
# fsp.traverse_safe "/Users/xurongzhi/test"
# .then (result) ->
#   console.log result
#   console.log '成功了哈哈'
#   fsp.traverse "/Users/xurongzhi/testw"
# .then ->
#   console.log '第二次成功'
#   # console.log e
# .catch (e) ->
#   console.log '失败了'
#   console.log e
# sandbox_path = "/Users/xurongzhi/.customize/sandbox/"
# app_id = "57be9c00e7e627a70e2f4975"
# pathDir = "#{sandbox_path}#{app_id}"
# console.log pathDir
# zipFile = "#{sandbox_path}#{app_id}.zip"
# zip(pathDir, zipFile)
# .then (result) ->
#   console.log "打包结果"
#   console.log result
# .catch (e) ->
# console.log e

# fsp.traverse_safe "/Users/xurongzhi/test/as"
# .then (result) ->
#   console.log result
#   all = _.map result, (each) ->
#     a =  "/Users/xurongzhi/test/bw#{each.substring(each.lastIndexOf('/'))}"
#     console.log a
#     fsp.copy each, a
#   Q.all all
# .then (a) ->
#   console.log "suc"
#   console.log a

# fsp.copy_safe "/Users/xurongzhi/test/rr", "/Users/xurongzhi/test/xxx"
# .then ->
#   console.log 'ok'
